﻿<MudNumericField @bind-Value="@Value"
                 Immediate="@true"
                 DebounceInterval="@DebounceInterval"
                 Required="@true"
                 RequiredError="Enter the number of stars" />
 
<MudButton Id="re-render"
           Variant="@Variant.Filled" 
           Color="@Color.Primary"
           OnClick="@LaunchDelayedRerender">
    Launch delayed re-render
</MudButton>
 
<MudText>
    RenderCount: @_renderCount
</MudText>

<MudText>
    Value: @Value
</MudText>
 
@code {
    public static string __description__ = "Test user input retention on component refresh before debounce.";
    
    [Parameter]
    public int Value { get; set; }

    public int DebounceInterval = 500;
    public int RerenderDelay = 2000;
    
    private int _renderCount;
    
    protected override void OnAfterRender(bool firstRender)
    {
        _renderCount++;
    }

    async Task LaunchDelayedRerender()
    {
        await Task.Delay(RerenderDelay);
        StateHasChanged();
    }
 }